package algorithm.stack;

import java.util.Random;

/**
 * @author bingo
 * @Description   链表栈与数组栈比较
 * @Date 2018/5/28
 */
public class Main {

    public static double testTime(Stack stack ,int count){

        long startTime = System.nanoTime();

        Random random = new Random();

        for(int i=0;i<count;i++){
            stack.push(random.nextInt(Integer.MAX_VALUE));
        }

        for(int i=0;i<count;i++){
            stack.pop();
        }

        long endTime = System.nanoTime();

        return  (endTime-startTime)/1000000000.0;
    }

    public static void main(String[] args) {
        int count = 100;

        ArrayStack arrayStack = new ArrayStack(count);
        LinkedListStack linkedListStack = new LinkedListStack();
        System.out.println("arrayStack--->"+ Main.testTime(arrayStack,count));
        System.out.println("linkedListStack--->"+ Main.testTime(linkedListStack,count));



    }
}
